<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('空调油费')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list" id ='csList'>
                    <ul>
                        <li>
                            <label>楼层：</label><!--  含有不同参数类型 -->
                            <select class="first form-control m-b col-sm-2" id="floorId" name="floorId">
                                <option value="">所有</option>
                            </select>
                        </li>
                        <li>
                            <label>租户：</label><!--  含有不同参数类型 -->
                            <select class="second form-control m-b col-sm-2" id="tenantId" name="tenantId">
                                <option value="">所有</option>
                            </select>
                        </li>
                        <li>
                            <label>时间：</label>
                            <input type="text" class="form-control" placeholder="请填写日期" id="etldt" name="etldt" />
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="sujian:airConditingCosts:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="sujian:airConditingCosts:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <!--<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="sujian:airConditingCosts:airImportData">-->
                <!--<i class="fa fa-upload"></i> 导入-->
            <!--</a>-->
            <a class="btn btn-info" onclick="calculate()" shiro:hasPermission="sujian:airConditingCosts:calculateValue">
                <i class="fa fa-adn"></i> 计算
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jquery-cxselect-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var data = [[${csList}]];
    $('#csList').cxSelect({
        selects: ['first', 'second'],
        required: true,
        jsonValue: 'v',
        data: data
    });
    var options;
    var prefix = ctx + "sujian/airConditioningCostsManagement";
    function query(){
        if(options!=null&&options!=undefined){
            var params = $("#bootstrap-table").bootstrapTable('getOptions');
            $("#bootstrap-table").bootstrapTable('refresh', params);
        }else{
            options = {
                url: prefix + "/airList",
                updateUrl: prefix + "/airEdit/{id}",
                importUrl: prefix + "/airImportData",
                exportUrl: prefix + "/airExport",
                importTemplateUrl: prefix + "/airImportTemplate",
                uniqueId:"powerUUID",
                modalName: "空调电费信息",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'powerUUID',
                        title: '主键',
                        visible: false
                    },
                    {
                        field: 'floorId',
                        title: '楼层id',
                        visible: false
                    },
                    {
                        field: 'floorName',
                        title: '楼层名'
                    },
                    {
                        field: 'tenantId',
                        title: '租户id',
                        visible: false
                    },
                    {
                        field: 'tenantName',
                        title: '租户名称'
                    },
                    {
                        field: 'tenantArea',
                        title: '租户面积'
                    },
                    {
                        field: 'publicPower',
                        title: '空调公用电'
                    },
                    {
                        field: 'avgPubPower',
                        title: '空调公用电分摊'
                    },
                    {
                        field: 'airPublicPower',
                        title: '空调电分摊'
                    },
                    {
                        field: 'avgAirPubPow',
                        title: '分摊金额'
                    },
                    {
                        field: 'etldt',
                        title: '批次日期'
                    },
                    {
                        field: 'cratetime',
                        title: '创建时间'
                    },
                    {
                        field: 'updatetime',
                        title: '更新时间'
                    }]
            };
            $.table.init(options);
        }

    }
    function calculate(){
        table.set();
        var url =  prefix + "/airCalculateValue";
        layer.open({
            type:1,
            title:["选择生成空调电费月份","font-size:18px"],
            area:["400px","180px"],
            shade:false,
            anim:3,
            shade:0.3,
            content:$("#etldtArea").html(),
            btn:['确认'],
            yes:function (index) {
                var etldt = $('#generateEtldt').val();
                if(etldt==null||etldt==""||etldt==undefined){
                    $.modal.alertError("请输入要生成空调电费的年月")
                    return;
                }
                $.ajax({
                    url:url,
                    type : "POST",
                    data : {
                        "etldt": etldt,
                    },
                    error : function(request) {
                        $.modal.alertError("系统错误");
                    },
                    success : function(data) {
                        $.operate.successCallback(data);
                    }
                })
            }
        })

        // var etldt = $("#etldt").val();
        // var data = {"etldt":etldt};
        // if (etldt == "" || etldt==null){
        //     $.modal.alertError("请选择生成空调电费的日期")
        //     return;
        // } else{
        //     $.operate.submit(url, "post", "json", data);
        // }

    }
</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果参数已经存在，更新这条数据。"> 是否更新已经存在的参数数据
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
<script type="text/template" id="etldtArea">
    <form class="mt20 mb10">
        <div style="margin: 20px;">
            <input type="text" class="form-control" id="generateEtldt" placeholder="请输入要生成的空调电费月份（yyyyMM）">
        </div>
    </form>
</script>
</html>